package com.lianbang.pharmacy.module.main

import com.lianbang.pharmacy.R
import cn.ubest.mvvmcore.base.BaseFragment
import android.os.Bundle
import android.view.View
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import cn.ubest.mvvmcore.utils.DoubleClickHelper
import com.lianbang.pharmacy.adapter.SearchMedicineByCategoryListAdapter
import com.lianbang.pharmacy.adapter.HomeSupplierListAdapter
import com.lianbang.pharmacy.databinding.FragmentSearchMedicineBinding
import com.lianbang.pharmacy.module.medicine.category.ProductCategoryActivity
import com.lianbang.pharmacy.module.search.SearchActivity
import com.lianbang.pharmacy.vm.MedicineVM
import kotlinx.android.synthetic.main.fragment_search_medicine.*

class SearchMedicineFragment : BaseFragment<MedicineVM, FragmentSearchMedicineBinding>() {

    companion object {
        fun newInstance(): SearchMedicineFragment {
            val fragment =
                SearchMedicineFragment()
            return fragment
        }
    }

    override fun initLayout(): Int {
        return R.layout.fragment_search_medicine
    }

    override fun initData(arguments: Bundle?) {

    }

    override fun initView(view: View) {
        btn_search.setOnClickListener(object : DoubleClickHelper.OnClickListener() {
            override fun onClicked(view: View) {
                SearchActivity.start(activity)
            }
        })
        btn_find_medicine.setOnClickListener(object : DoubleClickHelper.OnClickListener() {
            override fun onClicked(view: View) {
                ProductCategoryActivity.start(activity)
            }
        })

        btn_quality_supplier.setOnClickListener(object : DoubleClickHelper.OnClickListener() {
            override fun onClicked(view: View) {
                SupplierListActivity.start(activity)
            }
        })

        val searchAdapter = SearchMedicineByCategoryListAdapter()
        rv_search_medicine.layoutManager = GridLayoutManager(activity, 3)
        rv_search_medicine.adapter = searchAdapter
        searchAdapter.replaceData(mutableListOf("", "", "", "", "", "", "", ""))

        val supplierAdapter = HomeSupplierListAdapter()
        rv_supplier.layoutManager = LinearLayoutManager(activity)
        rv_supplier.adapter = supplierAdapter
        supplierAdapter.replaceData(mutableListOf("", "", "", "", "", "", "", ""))
    }

    override fun loadData() {

    }
}